<?php
namespace app\admin\service\pc;

use app\admin\service\BaseService;
use app\admin\model\pc\BoxPcTraySet;

/**
 * 频道分类服务类
 */
class BoxPcTraySetService extends BaseService
{
    /**
     * @var mixed
     */
    private $params;

    /**
     * 构造方法
     */
    public function __construct()
    {
        $this->model = new BoxPcTraySet();
        $this->params = request()->param();
    }

    /**
     * Desc : 获取数据列表
     * User : Steven
     * Date : 2024-05-22 18:11
     * @return array
     */
    public function getList(): array
    {
        $params = $this->params;
        $where   = [];
        $where[] =['mark','=',1];
        if (isset($params['status'])) {
            $where[] = ['status', '=',  $params['status']];
        }
        if (isset($params['title'])) {
            $where[] = ['title', 'like', '%' . $params['title'] . '%'];
        }
        if (isset($params['create_time'])) {
            $where[] = ['create_time', '>=',  $params['create_time'][0]];
            $where[] = ['create_time', '<=',  $params['create_time'][1]];
        }

        $result = $this->model
            ->where($where)
            ->order('sort', 'desc')
            ->paginate($params['limit'] ?? 10)
            ->toArray();
        return [
            'code'  => 0,
            'msg'   => 'success',
            'count' => $result['total'] ?? 0,
            'data'  => $result['data'] ?? [],
        ];
    }

    public function edit()
    {
        $params = $this->params;
        return parent::newEdit($params,false,true); // TODO: Change the autogenerated stub
    }

}